package com.xw.kotlinlib.app

import android.app.Activity
import android.app.Application
import android.os.Bundle

class ActivityStackCallbacks: Application.ActivityLifecycleCallbacks {
    
    companion object {
        /**
         * 当前activity数量
         */
        var activityCount = 0 
            private set
    }
    override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
        ActivityStack.getInstance().add(activity)
    }

    override fun onActivityStarted(activity: Activity) {
        activityCount++
    }

    override fun onActivityResumed(activity: Activity) {

    }

    override fun onActivityPaused(activity: Activity) {

    }

    override fun onActivityStopped(activity: Activity) {
        activityCount--
    }

    override fun onActivitySaveInstanceState(activity: Activity, p1: Bundle) {

    }

    override fun onActivityDestroyed(activity: Activity) {
        ActivityStack.getInstance().remove(activity)
    }
}